<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
Hello, {{ $username }}
<br>
<div id="showTest"></div>
<br>
<input type="text" id="username">
<button onclick="postData()">post获取数据</button>
<button onclick="getData()">get获取数据</button>
<script>
    function postData(){
        var username=$("#username").val();
       $.ajax({
           type:'post',
           url:'/user/index/mypost',
           data:{username:username},
           success:function (data) {
               $("#showTest").html(JSON.stringify(data.userinfo));
           }
       })
    }
    function getData(){
        var username=$("#username").val();
        $.ajax({
            type:'get',
            url:'/user/index/myget',
            data:{username:username},
            success:function (data) {
                $("#showTest").html(JSON.stringify(data.userinfo));
            }
        })
    }
</script>
</body>
